<template>
    <div class="hot">
        <div class="container">
            <div class="list">
                <ul>
                    <li v-for="(item, index) in arr">
                        <router-link :to=item.url>
                        <div class="num">
                            <span>{{ index+1 }}</span>
                        </div>
                        <div class="title">
                            <span>{{ item.title }}</span>
                        </div>
                        <div class="hotNum">
                            <span>{{ item.hot }}</span>
                        </div>
                        <div class="img">
                            <img src="../assets/img/hot1.png" alt="">
                        </div>
                    </router-link>
                    </li>
                </ul>
            </div>
            <div style="width: 100px;height: 60px;"></div>
        </div>
    </div>
</template>
<style lang="less">
.hot{
    width: 100%;
    background-color: #fff;
    .container{
        width: 94%;
        margin: 0 auto;
    }
    .list{
        width: 100%;
        ul{
            margin-top: 10px;
            width: 100%;
            li{
                width: 100%;
                margin-top: 10px;
                padding-bottom: 10px;
                position: relative;
                border-bottom: 1px solid #ccc;
                overflow: hidden;
                .num{
                    position: absolute;
                    top: 10px;
                    width: 27px;
                    text-align: center;
                    span{
                        font-size: 20px;
                        font-weight: bold; 
                        color: #ea8249;     
                    }
                }
                .title{
                    margin-left: 35px;
                    margin-top: 10px;
                    width: 70%;
                    font-size: 18px;
                    font-weight: bold;
                }
                .hotNum{
                    margin-left: 30px;
                    margin-top: 20px;
                    color: #909090;
                    font-size: 16px;
                }
                .img{
                    width: 18%;
                    position: absolute;
                    right: 0;
                    top: 10px;
                    img{
                        width: 100%;
                        border-radius: 10px;
                    }
                }
            }
        }
    }
}
</style>

<script>
import {hot} from '@/api/index'
export default {
    data(){
        return{
            arr:[],
        }
    },
    methods:{
        async getHot(){
            await hot()
                .then(content=>{
                    console.log('-->',content);
                    let {data} = content;
                    let newArr=data.map(item=>{
                        let obj = {}
                        obj.title=item.name;
                        obj.hot=item.hot;
                        obj.url=item.url;
                        return obj
                    })
                    this.arr=newArr
                })
        }
    },
    mounted(){
        this.getHot()
    },
}
</script>